package cn.dianhun.om.jpa.controller;

import cn.dianhun.om.jpa.pojo.TbUserEntity;
import cn.dianhun.om.jpa.repository.UserRepository;
import cn.dianhun.om.jpa.utills.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cyt
 * @create 2020-07-08 14:49
 */
@RequestMapping("/api")
@RestController
public class testUserController {
    @Autowired
    private UserRepository userRepository;


    @PostMapping("/query")
    public R query(@RequestBody TbUserEntity tbUserEntity) {
/*        private long userId;
        private String username;
        private String mobile;
        private String password;
        private Timestamp createTime;*/
        //创建匹配器，即如何使用查询条件
/*        ExampleMatcher matcher = ExampleMatcher.matching() //构建对象
                .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING) //改变默认字符串匹配方式：模糊查询
                .withIgnoreCase(true) //改变默认大小写忽略方式：忽略大小写
                .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.startsWith()) //地址采用“开始匹配”的方式查询
                .withIgnorePaths("createTime");  //忽略属性：是否关注。因为是基本类型，需要忽略掉*/
        //创建实例
        //Example<TbUserEntity> ex = Example.of(tbUserEntity, matcher);

        //查询
        // List<TbUserEntity> userEntities = userRepository.findAll(ex);

        return R.ok();
    }

}
